home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Directorty Opus 5 - Magellan
/
Opus 5 - Magellan.iso
/
Extras
/
DopusJPEG11
/
Pic2Jpeg.dopus5
< prev
next >
Wrap
Text File
|
1996-02-04
|
3KB
|
142 lines
/* Pic TO JPEG COMPRESSOR v1.1 [04-fev-96] for Directory Opus 5
By Christophe NOWAK
Need the JPEGVxBin Package with cjpeg and djpeg
ilbmtoppm needed for IFF Pictures.
pcxtoppm needed for PCX Pictures.
TODO : Support of PhotoCD and other formats
localisation ?
*/
parse arg portname scaleopt tmpdir option .
options results
if portname='' then
portname='DOPUS.1'
address value portname
lister query source
if rc>0 then do
dopus request '"Error - No source files" ok'
call end_script
end
parse var result handle .
lister set handle busy on
lister query handle path
if rc>0 then
call end_script
chemin=result
lister query handle selfiles stem files.
if files.count=0 then do
dopus request '"Error - No source files" ok'
call end_script
end
dopus getstring '"Enter Compression Quality" 3 "" Ok'
comp_quality=RESULT
if LENGTH(comp_quality)=3 then do
dopus request '"Error - Quality must be < 100" ok'
call end_script
end
lister set handle progress files.count 'Compressing Pictures...'
lister set handle title 'Compressing Pictures...'
lister refresh handle full
do i=0 to files.count-1
lister query handle abort
if result then
call end_script
lister set handle progress count i+1
lister set handle progress name files.i
lister query handle entry files.i stem fileinfo.
workfile='"'chemin||fileinfo.name'"'
if tmpdir=''|tmpdir='""' then
tmpfile='"'chemin||fileinfo.name||.tmp'"'
else tmpfile='"'tmpdir||fileinfo.name||.tmp'"'
ext=reverse(fileinfo.name)
parse var ext ext '.'
ext=upper(reverse(ext))
if ext='JPG'|ext='JPEG'|ext='JFIF' then do
destfile='"'chemin||fileinfo.name||.new'"'
if scaleopt='SCALE' then
call scalepic
else scale=''
address command 'djpeg 'scale' -outfile' tmpfile workfile
call Compress_File
end
if ext='GIF'|ext='TGA'|ext='TARGA'|ext='PPM'|ext='PBM' then do
call getfilename
destfile='"'chemin||truncfile||jpg'"'
address command 'cjpeg -optimize -quality' comp_quality option workfile '>'destfile
end
if ext='IFF'|ext='ILBM' then do
call getfilename
destfile='"'chemin||truncfile||jpg'"'
address command 'ilbmtoppm' workfile '>'tmpfile
call Compress_File
end
if ext='PCX' then do
call getfilename
destfile='"'chemin||truncfile||jpg'"'
address command 'pcxtoppm' workfile '>'tmpfile
call Compress_File
end
lister select handle '"'fileinfo.name'"' off
lister refresh handle full
end
/* Comment the 5 following lines if you never want to delete the old files */
if files.count>0 then do
dopus request '"Delete old files ?" Ok|Cancel'
if RC>0 then
call deleteold
end
call end_script
deleteold:
do i=0 to files.count-1
address command 'delete' '"'chemin||fileinfo.name'"'
end
return
scalepic:
dopus request '"Select Scale Factor" 2|4|8|16|32|64|128|256|None'
if rc=0 then
scale=''
else scale='-scale 1/'||2**rc
return
getfilename:
truncfile = SUBSTR(fileinfo.name,1,LENGTH(fileinfo.name)-LENGTH(ext))
return
Compress_File:
address command 'cjpeg -optimize -quality' comp_quality option tmpfile '>'destfile
address command 'delete' tmpfile
return
Error:
dopus request '"Error in command - Sorry" ok'
end_script:
lister set handle title
lister refresh handle full
lister set handle busy off
EXIT